package com.yanqu.road.server.cmd.activity.xiuxian;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.XiuXianProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.xiuxian.CrossXiuXianMgr;
import com.yanqu.road.server.manager.activity.xiuxian.activity.CrossXiuXianActivity;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;

@Cmd(code = CrossProtocol.C_CROSS_XIU_XIAN_GET_PVP_END_DATA, desc = "跨服取下pvp结束数据")
public class CrossXiuXianGetPvpEndDataCmd extends CrossCommand {

    private int activityId;

    private long userId;

    private int endRound;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        XiuXianProto.CrossXiuXianGetPvpEndDataReqMsg reqMsg = XiuXianProto.CrossXiuXianGetPvpEndDataReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        userId = packet.getPlayerId();
        endRound = reqMsg.getEndRound();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossXiuXianActivity activity = CrossXiuXianMgr.getActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_XIU_XIAN_ACTIVITY_NOT_FOUND;
            return;
        }
        ret = activity.getPvpEndData(userId, endRound);
    }

    @Override
    public void sendData() {

    }
}
